<?php
require_once '../sub/init.php';
if(is_weixin() && empty($cook_openid)){
	$cook_openid = wx_get_openid();
	setcookie("cook_openid",$cook_openid,time()+31536000,"/",$_ZEAI['CookDomain']);
}
$currfields = 'sex,grade,openid,subscribe,money';
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/config_vip.php';
$cook_grade = intval($row['grade']);
$cook_sex   = intval($row['sex']);
$cook_money = $row['money'];
$cook_openid= $row['openid'];
$cook_subscribe = $row['subscribe'];
if($submitok=='ajax_top_free'){
	if(!ifint($objid))json_exit(array('flag'=>0,'msg'=>'请选择置顶天数'));
	$row = $db->ROW(__TBL_TOP__,"day,json_price","id=".$objid,"name");
	if (!$row)json_exit(array('flag'=>0,'msg'=>'请选择置顶天数'));
	$day= $row['day'];
	$json_price = json_decode($row['json_price'],true);
	$price=intval($json_price[$cook_sex.'_'.$cook_grade]);
	if($price!=0)json_exit(array('flag'=>0,'msg'=>'置项验证错误，请联系管理员'));
	//
	$row = $db->ROW(__TBL_TOP_U__,"day,addtime2","uid=".$cook_uid);
	if($row){
		$day_new = $row['day']+$day;
		$addtime2_new=$row['addtime2']+86400*$day;
		$db->query("UPDATE ".__TBL_TOP_U__." SET day=$day_new,addtime2=$addtime2_new WHERE uid=".$cook_uid);
	}else{
		$addtime2=ADDTIME+86400*$day;
		$db->query("INSERT INTO ".__TBL_TOP_U__."  (fid,uid,day,addtime1,addtime2) VALUES ($objid,$cook_uid,$day,".ADDTIME.",$addtime2)");
	}
	json_exit(array('flag'=>1,'msg'=>'置项成功'));
}
?>
<!doctype html><html><head><meta charset="utf-8">
<title>我的-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/my_top.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/my_top.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.top_mini4{background-image:url("<?php echo RES;?>m/img/my_bg.png")}
header.bgcolor,#nextbtn{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#nextbtn {box-shadow:0 .3rem .8rem rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)}
.my_top_cz em.ed{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1);color:<?php echo $_ZEAI['mob_mbcolor'];?>}
<?php
if ($_ZEAI['m_mb']==2){
	$mini_class='top_mini4';
	echo '.TRnav_btn i{color:'.$_ZEAI['mob_mbcolor'].'}';
}else{
	$mini_class='top_mini4 zeaibg bgcolor yunbox';
}
?>
</style>
<script>var winh=<?php echo (is_weixin())?30.5:37.5;?></script>
</head>
<body>
<?php
$mini_title='置顶相亲';
require_once ZEAI.'m/top_mini.php';?>
<div class="my_top">
	<div class="bigico ico">&#xe60c;</div>
    <h1>首页置顶尊享特权</h1>
    <h4>首页黄金展示专区，受众率最大，相亲成功率暴增</h4>
</div>
<br>
<div class="my_top_cz" id="numlist">
    <?php
	$rt = $db->query("SELECT id,day,json_price FROM ".__TBL_TOP__." WHERE flag=1 ORDER BY px DESC,id DESC");
	$total = $db->num_rows($rt);
	if ($total == 0) {
		echo "管理员很懒，未定义置顶项目";
	} else {
		for($i=1;$i<=$total;$i++) {
			$rows = $db->fetch_array($rt,'name');
			if(!$rows) break;
			$id  = $rows['id'];
			$day = $rows['day'];
			$json_price = json_decode($rows['json_price'],true);
			$my_price=floatval($json_price[$cook_sex.'_'.$cook_grade]);
			$cls=($i==1)?' class="ed"':'';
			if($i==1){
				$cls=' class="ed"';$objid=$id;
			}else{
				$cls='';
			}
			echo '<em objid="'.$id.'" rmb="'.$my_price.'"'.$cls.'><h3>置顶'.$day.'天</h3><b>'.$my_price.'</b></em>';
		}
	}
    ?>
</div>
<div class="clear"></div><br>
<div class="linebox"><div class="line W50"></div><div class="title BAI">置顶显示标准</div></div>
<div class="my_top_tips">
● 个人资料必须完整，如头像、生日、身高、昵称等，如果没填请　<a  href="my_info.php"><i class="ico">&#xe610;</i> 立即完善</a><br>
● 个人资料资料已通过审核<br>
● 个人资料状态非隐藏状态<br>
</div>
<?php
if ($total > 0){
	$jump_url = HOST.'/m/my_top.php';
	$money = 0;
	$kind  = 19;
	echo '<input type="hidden" id="money" value="'.$money.'">';
	echo '<input type="hidden" id="objid" value="'.$objid.'">';
	?>
	<a id="nextbtn">确认支付</a>
    <?php require_once 'my_pay.php';?>
<?php }?>
<?php require_once ZEAI.'m/TRnav.php';?>
</body></html>